package vn.com.aptech.msh.controller;

import java.io.Serializable;
import javax.annotation.PostConstruct;

import javax.enterprise.context.RequestScoped;
import javax.faces.event.ValueChangeEvent;
import javax.inject.Inject;
import javax.inject.Named;
import vn.com.aptech.msh.business.IEstateBean;
import vn.com.aptech.msh.entities.Advertising;

/**
 *
 * @author trietto
 */
@Named("detailController")
@RequestScoped
public class AdvertisementDetailController implements Serializable {

    private int advId;
    @Inject
    IEstateBean estateBusiness;
    Advertising model = null;

    @PostConstruct
    public void init() {
    }

    public boolean isExists() {
        return (model != null);
    }

    public boolean isSellingHouse() {
        return model.getSellingHouse() != null;
    }

    public boolean isRentalBasis() {
        return model.getRentalBasisAccommodation() != null;
    }

    public boolean isPayingGuest() {
        return model.getPayingGuestAccommodation() != null;
    }

    public void onReceiveAdvId(ValueChangeEvent vce) {
        int nId = Integer.valueOf(vce.getNewValue().toString());
        model = estateBusiness.findAdvertisingById(nId);
    }

    public int getAdvId() {
        return advId;
    }

    public void setAdvId(int advId) {
        this.advId = advId;
    }

    public Advertising getModel() {
        return model;
    }

    public void setModel(Advertising model) {
        this.model = model;
    }
}
